package com.demo.apparel.mapper.web;

import com.demo.apparel.dto.ClothesByCategoryDTO;
import com.demo.apparel.entity.Clothes;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface WebClothesByCategoryMapper {
    @Select("""
        SELECT id, name, image_url, description, season, status_sale, update_time
        FROM clothes
        WHERE category = #{category}
        ORDER BY update_time DESC
        LIMIT #{offset}, #{pageSize}
    """)
    List<ClothesByCategoryDTO> getClothesByCategory(@Param("category") int category,
                                                    @Param("offset") int offset,
                                                    @Param("pageSize") int pageSize);

    @Select("SELECT COUNT(*) FROM clothes WHERE category = #{category}")
    long getClothesCountByCategory(@Param("category") int category);



}
